i64 exgcd(i64 a, i64 b, int &x, int &y) {
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    auto d = exgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}